﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Serialization;
using DLL;
using DLL.Entities;

namespace COM
{
    public partial class COM : Form
    {
        public COM()
        {
            InitializeComponent();
        }

        string cwd = System.IO.Directory.GetCurrentDirectory();

        private void COM_Load(object sender, EventArgs e)
        {

        }

        private void btn_Fire_Click(object sender, EventArgs e)
        {
            //cwd = cwd.Replace("\\bin\\Debug", "");
            //Missile Mis_Obj = new Missile();
            //Mis_Obj.misCount = 50;
            //XmlSerializer serializer = new XmlSerializer(typeof(Missile));
            //Mis_Obj = (Missile)XMLHandler.WriteXML(Mis_Obj, "Missiles_Serialzed.xml", serializer);
            //Mis_Obj.misCount -= 1;
            //if (Mis_Obj.misCount == 0)
            //{
            //    MessageBox.Show("You Are Out of Missiles!");
            //}
        }

        private void btn_Des_Click(object sender, EventArgs e)
        {
                Bogey Bog_Obj = new Bogey();
                XmlSerializer serializer = new XmlSerializer(typeof(Bogey));
                //here you gotta type cast the object into a type of class bogey
                Bog_Obj =(Bogey) XMLHandler.ReadXML("../../../RAD/bin/Debug/Bogey_Serialzed.xml", serializer);
                MessageBox.Show("Deserialization Complete");

                txtBox_Speed.Text = Bog_Obj.Speed;
                txtBox_Alt.Text = Convert.ToString(Bog_Obj.Altitude);
                txtBox_Dist.Text = Bog_Obj.Distance;
                txtBox_TL.Text = Convert.ToString(Bog_Obj.ThreatLevel);


        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            RadStatus Status_Obj = new RadStatus();
            XmlSerializer serializer = new XmlSerializer(typeof(RadStatus));
            Status_Obj = (RadStatus)XMLHandler.ReadXML("../../../RAD/bin/Debug/RadStatus_Serialzed.xml", serializer);

            if (Status_Obj.radStatus == Status_Obj.radStatus +1)
            {
                lbl_Stat.Text = "RADAR OFFLINE!";
            }
            else
            {
                lbl_Stat.Text = "RADAR ONLINE!";
            }
        }
           
        }
    }



 
